package card;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author And(yanqingyuan)
 * @Date 2022/9/4 12:41
 * @Details
 */
public class test222 {
    public static void main(String[] args) {
//        List<String> strings = getLeaders("陈栋，肖川东，刘隆怡");
//        System.out.println(getLeadersToString(strings));
        System.out.println(toRemoveSpace("000000000000"));
    }
    public static List<String> getLeaders(String leaderStr){
        leaderStr.replaceAll("，",",").replaceAll(" ","");
        List<String> list=new ArrayList<>();
        char[] chars = leaderStr.toCharArray();
        StringBuffer temp=new StringBuffer();
        for (char c : chars) {
            if (c==',' || c=='，')
            {
                list.add(String.valueOf(temp));
                temp=new StringBuffer();
                continue;
            }
            temp.append(c);
        }
        if (temp.length()>0){
            list.add(temp.toString());
        }
        return list;
    }

    public static String getLeadersToString(List<String> leaders){
        StringBuffer temp=new StringBuffer();
        for (int i = 0; i < leaders.size(); i++) {
            if (i==0){
                temp.append("(");
            }
            temp.append("'"+leaders.get(i)+"',");
        }
        //将最后一位替换为括号
        temp.replace(temp.length()-1,temp.length(),")");
        return temp.toString();
    }

    public static String toRemoveSpace(String s){
        char[] chars = s.toCharArray();
        int deep=0;
        for (int i = chars.length - 1; i >= 0; i--) {
            if (chars[i]!='0'){
                break;
            }
            deep=i;
        }
        return s.substring(0, deep);
    }
}
